package 自定义类加载器;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

public class MyClassLoader extends ClassLoader {
    private static final String MESSAGE_CLASS_PATH = "D" + File.separator + "Message.class";

    private byte[] loadClassData() throws Exception {
        byte data[] = null;
        try (

                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                InputStream is = new FileInputStream(new File(MESSAGE_CLASS_PATH)); // 文件流加载
                // 字节数据取出

        ) {
            // is.transferTo(bos); 					// 读取数据
            data = bos.toByteArray();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return data;
    }
}
